package com.tca.spring.framework.learning.ioc;

import com.tca.spring.framework.learning.ioc.config.FactoryBeanConfiguration;
import com.tca.spring.framework.learning.ioc.factorybean.Student;
import com.tca.spring.framework.learning.ioc.factorybean.StudentFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author zhoua
 * @Date 2021/5/2
 */
public class SpringFactoryBeanStarter {

    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(FactoryBeanConfiguration.class);
        Student student = applicationContext.getBean(Student.class);
        Object obj1 = applicationContext.getBean("studentFactoryBean");
        System.out.println(student == obj1);
        StudentFactoryBean studentFactoryBean = applicationContext.getBean(StudentFactoryBean.class);
        Object obj2 = applicationContext.getBean("&studentFactoryBean");
        System.out.println(studentFactoryBean == obj2);
    }
}
